﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Baimasoft.Web.UI;
using Baimasoft.Manage.SqlServerDAL;

public partial class DocumentManage_DocumnetHistoryList : Baimasoft.Web.UI.PageManagerTop
{
    LogManage MyLog = new LogManage();

    protected void Page_Load(object sender, EventArgs e)
    {
        this.BindControlEvent();
        if (!this.IsPostBack)
        {
            GridView1.Attributes.Add("BorderColor", "LightSkyBlue");
            sSTime.Text = DateTime.Now.ToString("yyyy-MM") + "-01";
            sETime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);

            this.BindGridViewData();//绑定GridView,为删除服务
        }
    }

    protected override void BindGridViewData()
    {
        this.DataSource = MyLog.SearchLogInfo(GetSearchString());
        this.DataSource.DefaultView.Sort = this.SortString;
        GridView1.DataSource = this.DataSource.DefaultView;
        GridView1.DataBind();
    }

    protected override string GetSearchString()
    {
        string searchStr = "(1=1)";

        searchStr += " and a.type='3' ";

        string sTxtContent = TxtContent.Text.ToString().Trim();
        if (sTxtContent != "")
        {
            searchStr += " and content like'%" + sTxtContent + "%' ";
        }
        
        string sTempDate = sSTime.Text.ToString().Trim(); //开始日期
        if (sTempDate != "")
        {
            string sSHour = SHour.Value.ToString().Trim();
            string sSMinute = SMinute.Value.ToString().Trim();
            string sStarDate = sTempDate + " " + sSHour + ":" + sSMinute;
            searchStr += " and a.OpDT >= '" + sStarDate + "'";
        }

        string sTempDate2 = sETime.Text.ToString().Trim();  //结束日期
        if (sTempDate2 != "")
        {
            string sEHour = EHour.Value.ToString().Trim();
            string sEMinute = EMinute.Value.ToString().Trim();
            string sEndDate = sTempDate2 + " " + sEHour + ":" + sEMinute;
            searchStr += " and a.OpDT <= '" + sEndDate + "'";
        }
        return searchStr;
    }

    protected new void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            if (e.Row.RowIndex % 2 != 0)
            {
                e.Row.Attributes.Add("onclick", "tog(this,'#EFEFF8')");
            }
            else
            {
                e.Row.Attributes.Add("onclick", "tog(this,'#F9F9FB')");
            }
        }
    }

}
